home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Macintosh Tracker Source / Tracker Client Folder / CNumberEdit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-23  |  2.2 KB  |  129 lines  |  [TEXT/KAHL]

  1. /* CNumberEdit.c */
  2.  
  3. #include "CNumberEdit.h"
  4. #include "Memory.h"
  5. #include "CWindow.h"
  6. #include "MenuController.h"
  7.  
  8.  
  9. #define CHANGEINTERVAL (120)
  10.  
  11.  
  12. void                CNumberEdit::INumberText(LongPoint TheStart, LongPoint TheExtent,
  13.                                     short TheFontID, short ThePointSize, CWindow* TheWindow,
  14.                                     CEnclosure* TheEnclosure)
  15.     {
  16.         ITextEdit(TheStart,TheExtent,NIL,SelectText,TheFontID,ThePointSize,TheWindow,
  17.             TheEnclosure);
  18.         Dirty = False;
  19.     }
  20.  
  21.  
  22. MyBoolean        CNumberEdit::DoKeyDown(MyEventRec Event)
  23.     {
  24.         switch ((uchar)(Event.Message & charCodeMask))
  25.             {
  26.                 case 0x08:
  27.                 case 0x09:
  28.                 case '0':
  29.                 case '1':
  30.                 case '2':
  31.                 case '3':
  32.                 case '4':
  33.                 case '5':
  34.                 case '6':
  35.                 case '7':
  36.                 case '8':
  37.                 case '9':
  38.                     Dirty = True;
  39.                  DoSomethingPoint:
  40.                     LastChange = TickCount();
  41.                     return inherited::DoKeyDown(Event);
  42.                 case (uchar)0x1c:  /* macintosh left arrow */
  43.                 case (uchar)0x1d:  /* macintosh right arrow */
  44.                     goto DoSomethingPoint;
  45.                 case 13:
  46.                     StoreValue();
  47.                     return True;
  48.                 default:
  49.                     return False;
  50.             }
  51.     }
  52.  
  53.  
  54. MyBoolean        CNumberEdit::DoMenuCommand(ushort MenuCommandValue)
  55.     {
  56.         if (inherited::DoMenuCommand(MenuCommandValue))
  57.             {
  58.                 Dirty = True;
  59.                 LastChange = TickCount();
  60.                 return True;
  61.             }
  62.          else
  63.             {
  64.                 return False;
  65.             }
  66.     }
  67.  
  68.  
  69. void                CNumberEdit::DoIdle(long Stupid)
  70.     {
  71.         inherited::DoIdle(Stupid);
  72.         if ((TickCount() - LastChange > CHANGEINTERVAL) && Dirty)
  73.             {
  74.                 StoreValue();
  75.             }
  76.     }
  77.  
  78.  
  79. MyBoolean        CNumberEdit::RelinquishKeyReceivership(void)
  80.     {
  81.         StoreValue();
  82.         return inherited::RelinquishKeyReceivership();
  83.     }
  84.  
  85.  
  86. void                CNumberEdit::StoreValue(void)
  87.     {
  88.         Dirty = False;
  89.     }
  90.  
  91.  
  92. long                CNumberEdit::GetValue(void)
  93.     {
  94.         long            Result;
  95.         Handle        Temp;
  96.  
  97.         Temp = GetTextCopy();
  98.         Result = String2Int(Temp);
  99.         ReleaseHandle(Temp);
  100.         return Result;
  101.     }
  102.  
  103.  
  104. void                CNumberEdit::SetValue(long Value)
  105.     {
  106.         Handle        Temp;
  107.  
  108.         Temp = Int2String(Value);
  109.         HLock(Temp);
  110.         TESetText(*Temp,HandleSize(Temp),TextBox);
  111.         DoUpdate();
  112.         ReleaseHandle(Temp);
  113.         CTextEdit::DoMenuCommand(mEditSelectAll);
  114.         Dirty = False;
  115.     }
  116.  
  117.  
  118. void                CNumberEdit::DoDisable(void)
  119.     {
  120.         Handle        Temp;
  121.  
  122.         inherited::DoDisable();
  123.         Temp = AllocHandle(0);
  124.         HLock(Temp);
  125.         TESetText(*Temp,HandleSize(Temp),TextBox);
  126.         DoUpdate();
  127.         ReleaseHandle(Temp);
  128.     }
  129.